﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

namespace AppDataStruct
{
    [Serializable]
    [XmlRoot("GAZApplyInfo")]
    public class GAZApplyInfo
    {
        private string _ywbh;
        [XmlElement("YWBH")]
        public string YWBH
        {
            get { return _ywbh; }
            set { _ywbh = value; }
        }

        private string _WSQ;
        [XmlElement("WSQ")]
        public string WSQ
        {
            get { return _WSQ; }
            set { _WSQ = value; }
        }

        private string _WSQ_File;
        [XmlElement("WSQ_File")]
        public string WSQ_File
        {
            get { return _WSQ_File; }
            set { _WSQ_File = value; }
        }

        private string _wsz;
        [XmlElement("WSZ")]
        public string WSZ
        {
            get { return _wsz; }
            set { _wsz = value; }
        }


        private string _jpz;
        [XmlElement("JPZ")]
        public string JPZ
        {
            get { return _jpz; }
            set { _jpz = value; }
        }

        private string _md5;
        [XmlElement("MD5")]
        public string MD5
        {
            get { return _md5; }
            set { _md5 = value; }
        }

        private string _md5_file;
        [XmlElement("MD5_File")]
        public string MD5_File
        {
            get { return _md5_file; }
            set { _md5_file = value; }
        }

        private string _err;
        [XmlElement("ERR")]
        public string ERR
        {
            get { return _err; }
            set { _err = value; }
        }

        private string _err_file;
        [XmlElement("ERR_File")]
        public string ERR_File
        {
            get { return _err_file; }
            set { _err_file = value; }
        }

        private string _tpl;
        [XmlElement("TPL")]
        public string TPL
        {
            get { return _tpl; }
            set { _tpl = value; }
        }

        private string _tpl_file;
        [XmlElement("TPL_File")]
        public string TPL_File
        {
            get { return _tpl_file; }
            set { _tpl_file = value; }
        }

        /// <summary>
        /// 手写签名
        /// </summary>
        private string _sqxm;
        [XmlElement("SXQM")]
        public string SXQM
        {
            get { return _sqxm; }
            set { _sqxm = value; }
        }

        /// <summary>
        /// 证件号码
        /// </summary>
        private string _zjhm;
        [XmlElement("ZJHM")]
        public string ZJHM
        {
            get { return _zjhm; }
            set { _zjhm = value; }
        }

        /// <summary>
        /// 证件有效日期
        /// </summary>
        private string _zjyxqz;
        [XmlElement("ZJYXQZ")]
        public string ZJYXQZ
        {
            get { return _zjyxqz; }
            set { _zjyxqz = value; }
        }

        /// <summary>
        /// 签发日期
        /// </summary>
        private string _qfrq;
        [XmlElement("QFRQ")]
        public string QFRQ
        {
            get { return _qfrq; }
            set { _qfrq = value; }
        }

        /// <summary>
        /// 业务类别
        /// </summary>
        private CodeMap _ywlb = new CodeMap();

        public CodeMap YWLB
        {
            get { return _ywlb; }
            set { _ywlb = value; }
        }

        /// <summary>
        /// 是否加签注
        /// </summary>
        private CodeMap _sfqz = new CodeMap(); 

        public CodeMap SFQZ
        {
            get { return _sfqz; }
            set { _sfqz = value; }
        }

        private List<LabelApplyInfo> _sczqz = new List<LabelApplyInfo>();
        [XmlArray("SCZQZ")]
        [XmlArrayItem("QZ")]
        public List<LabelApplyInfo> SCZQZ
        {
            get { return _sczqz; }
            set { _sczqz = value; }
        }
        private string _qsxm;

        public string QSXM
        {
            get { return _qsxm; }
            set { _qsxm = value; }
        }
        private CodeMap _qsxb = new CodeMap();

        public CodeMap QSXB
        {
            get { return _qsxb; }
            set { _qsxb = value; }
        }

        private string _qssfzh;

        public string QSSFZH
        {
            get { return _qssfzh; }
            set { _qssfzh = value; }
        }
        private CodeMap _qsgx = new CodeMap();

        public CodeMap QSGX
        {
            get { return _qsgx; }
            set { _qsgx = value; }
        }
        private string _lxzjhm;

        /// <summary>
        /// 旅行证件号码
        /// </summary>
        public string LXZJHM
        {
            get { return _lxzjhm; }
            set { _lxzjhm = value; }
        }

        private string _hkmacaononow;
        [XmlElement("HKMacaoNoNow")]
        public string HKMacaoNoNow
        {
            get { return _hkmacaononow; }
            set { _hkmacaononow = value; }
        }

        private string _hkmacaovalidity;
        [XmlElement("HKMacaoValidity")]
        public string HKMacaoValidity
        {
            get { return _hkmacaovalidity; }
            set { _hkmacaovalidity = value; }
        }

        private string paperStatus;
        [XmlElement("PaperStatus")]
        public string PaperStatus
        {
            get { return paperStatus; }
            set { paperStatus = value; }
        }

        public void Reset()
        {
            _ywbh = "";
            _wsz = "";
            _WSQ = "";
            _jpz = "";
            _err = "";
            _md5 = "";
            _tpl = "";
            _qsxb.Reset();
            _qsgx.Reset();
            _qsxm = "";
            _sczqz.Clear();
            _qssfzh = "";
            _lxzjhm = "";
            _sqxm = "";
            _sfqz.Reset();
            _ywlb.Reset();
        }

        public LabelApplyInfo GetLabelInfo(string qwd)
        {
            int index = SCZQZ.FindIndex(r=>r.QWD.Code == qwd);
            if(index >= 0)
            {
                return SCZQZ[index];
            }
            else
            {
                return null;
            }
        }

        public void SetLabelInfo(LabelApplyInfo info)
        {
            if(string.IsNullOrEmpty(info.QWD.Code))
            {
                return;
            }
            int index = SCZQZ.FindIndex(r => r.QWD.Code == info.QWD.Code);
            if (index >= 0)
            {
                SCZQZ[index] = info;
            }
            else
            {
                SCZQZ.Add(info);
            }
        }
    }
}

